/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scm.rawMaterialPurchasing.managedbean;

import commonInfrastructure.accountManagement.entity.EmployeeEntity;
import commonInfrastructure.accountManagement.session.EmailSessionBean;
import commonInfrastructure.accountManagement.session.EmployeeSessionBean;
import commonInfrastructure.internalMessaging.session.MessageSessionBean;
import crm.salesOrderProcessing.entity.ProductEntity;
import crm.salesOrderProcessing.session.ProductManageSessionBean;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.EJBException;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.PhaseEvent;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpServletRequest;
import mrp.productionPlanning.entity.WeeklyDetailEntity;
import mrp.productionPlanning.session.WeeklyDetailSessionBean;
import scm.inventoryControl.session.stateless.InventoryControlSessionBean;
import scm.rawMaterialPurchasing.entity.BOMLineItemEntity;
import scm.rawMaterialPurchasing.entity.RawMaterialEntity;
import scm.rawMaterialPurchasing.entity.RawMaterialPurchasingOrderEntity;
import scm.rawMaterialPurchasing.entity.RawMaterialPurchasingOrderLineItemEntity;
import scm.rawMaterialPurchasing.entity.RawMaterialRequirementLineItemEntity;
import scm.rawMaterialPurchasing.entity.RawMaterialRequirementEntity;
import scm.rawMaterialPurchasing.entity.SupplierLineItemEntity;
import scm.rawMaterialPurchasing.session.BOMSessionBean;
import scm.rawMaterialPurchasing.session.RawMaterialPurchasingSessionBean;
import scm.rawMaterialPurchasing.session.SupplierSessionBean;

/**
 *
 * @author ReinforceII
 */
@ManagedBean
@ViewScoped
public class CreateRawMaterialPurchasingManagedBean {

    @EJB
    BOMSessionBean bOMSessionBean;
    @EJB
    SupplierSessionBean supplierSessionBean;
    @EJB
    RawMaterialPurchasingSessionBean rawMaterialPurchasingSessionBean;
    @EJB
    EmailSessionBean emailSessilnBean;
    @EJB
    MessageSessionBean messageSessionBean;
    @EJB
    EmployeeSessionBean employeeSessionBean;
    @EJB
    InventoryControlSessionBean inventoryControlSessionBean;
    @EJB
    WeeklyDetailSessionBean weeklyDetailSessionBean;
    @EJB
    ProductManageSessionBean productManagementSessionBean;
    private List<RawMaterialPurchasingOrderLineItemEntity> purchasingList;
    private RawMaterialRequirementEntity rawMaterialRequirement;
    private RawMaterialEntity rawMaterial;
    private RawMaterialPurchasingOrderLineItemEntity rawMaterialPurchasingOrderLineItem;
    private RawMaterialPurchasingOrderEntity rawMaterialPurchasingOrder;
    private List<RawMaterialPurchasingOrderEntity> rawMaterialPurchasingOrderList;
    private Long rawMaterialId;
    private Long supplierLineItemId;
    private int lotQuantity;
    private int lotSize;
    private double requiredQuantity;
    private double totalQuantity;
    private double unitPrice;
    private double cumAmount;
    private List<SelectItem> listOfSuppliers;
    private boolean nothingAdded;
    private Long currentUserId;
    private double weekOneRequired;
    private double weekTwoRequired;
    private double weekThreeRequired;
    private double weekOneIncoming;
    private double weekTwoIncoming;
    private double weekThreeIncoming;
    private double weekOneEstQuantityLeft;
    private double weekTwoEstQuantityLeft;
    private double weekThreeEstQuantityLeft;
    private double estQuantityLeft;
    private double currentRawMaterialInventoryLevel;
    private boolean render = false;
    private double plannedOrderingQuantity;
    private double weekonePlan;
    private double weektwoPlan;
    private double weekthreePlan;
    ProductEntity productA;
    ProductEntity productB;
    ProductEntity productC;
    ProductEntity productD;

    /** Creates a new instance of CreateRawMaterialPurchasingManagedBean */
    public CreateRawMaterialPurchasingManagedBean() throws IOException {
    }

    public void initView(PhaseEvent event) {
        purchasingList = new ArrayList();
        if (rawMaterialRequirement == null) {
            rawMaterialRequirement = (RawMaterialRequirementEntity) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("rawMaterialRequirement");
        }
        if (rawMaterial == null) {
            rawMaterial = new RawMaterialEntity();
        }
        rawMaterialPurchasingOrderLineItem = new RawMaterialPurchasingOrderLineItemEntity();
        listOfSuppliers = new ArrayList();
        rawMaterialPurchasingOrder = new RawMaterialPurchasingOrderEntity();
        rawMaterialPurchasingOrderList = new ArrayList();

    }

    public double getSafetyStock() {
        System.out.print("Inside Test...." + rawMaterial.getRawMaterialName());
        try {
            return inventoryControlSessionBean.getInventoryByRMName(rawMaterial.getRawMaterialName()).getSafetyStock();
        } catch (EJBException ex) {
            return 0;
        }
    }

    public double getSafetyStock(Long rawMaterialId) {
        
        try {
            System.out.println(inventoryControlSessionBean.getInventoryByRMName(bOMSessionBean.getRawMaterialById(rawMaterialId).getRawMaterialName()).getSafetyStock());

            return inventoryControlSessionBean.getInventoryByRMName(bOMSessionBean.getRawMaterialById(rawMaterialId).getRawMaterialName()).getSafetyStock();
        } catch (EJBException ex) {
            return 0;
        }
    }

    public void addLineItem(ActionEvent event) {

        if (supplierLineItemId == null) {
            return;
        }
        if (isExistingLingItem()) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "This line item already exists.", ""));
            return;
        }
        rawMaterialPurchasingOrderLineItem.setRawMaterial(bOMSessionBean.getRawMaterialById(rawMaterialId));

        rawMaterialPurchasingOrderLineItem.setLotQuantity(lotQuantity);
        rawMaterialPurchasingOrderLineItem.setTotalQuantity(lotSize * lotQuantity);

        rawMaterialPurchasingOrderLineItem.setSupplierLineItemEntity(supplierSessionBean.getSupplierLineItemByID(supplierLineItemId));
        rawMaterialPurchasingOrderLineItem.setCumAmount(lotSize * lotQuantity * unitPrice);

        purchasingList.add(rawMaterialPurchasingOrderLineItem);

        rawMaterialPurchasingOrderLineItem = new RawMaterialPurchasingOrderLineItemEntity();


        return;

    }

    private void autoAddLineItem() {

        if (supplierLineItemId == null) {
            return;
        }
        if (isExistingLingItem()) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "This line item already exists.", ""));
            return;
        }
        rawMaterialPurchasingOrderLineItem.setRawMaterial(bOMSessionBean.getRawMaterialById(rawMaterialId));

        rawMaterialPurchasingOrderLineItem.setLotQuantity(lotQuantity);
        rawMaterialPurchasingOrderLineItem.setTotalQuantity(lotSize * lotQuantity);

        rawMaterialPurchasingOrderLineItem.setSupplierLineItemEntity(supplierSessionBean.getSupplierLineItemByID(supplierLineItemId));
        rawMaterialPurchasingOrderLineItem.setCumAmount(lotSize * lotQuantity * unitPrice);

        purchasingList.add(rawMaterialPurchasingOrderLineItem);

        rawMaterialPurchasingOrderLineItem = new RawMaterialPurchasingOrderLineItemEntity();


        return;

    }

    public void autoGeneratePurchasingOrders(ActionEvent event) {

        for (RawMaterialRequirementLineItemEntity lineItem : rawMaterialRequirement.getRawMaterialRequirementLineItems()) {

            rawMaterialId = lineItem.getRawMaterial().getId();
            lotSize = lineItem.getRawMaterial().getLotSize();
            calculateEstQuantityLeft(lineItem.getRawMaterial().getId());

            totalQuantity = 0;
            lotQuantity = 0;

            while (totalQuantity < lineItem.getQuantity() - estQuantityLeft) {

                lotQuantity++;
                totalQuantity = lotSize * lotQuantity;
            }
            Long lowestId = null;
            double lowestPrice = 0;
            for (SupplierLineItemEntity supplierLineItem : lineItem.getRawMaterial().getSupplierLineItemList()) {

                if (lowestId == null) {
                    lowestId = supplierLineItem.getId();
                    lowestPrice = supplierLineItem.getPrice();
                    continue;
                }

                if (lowestPrice > supplierLineItem.getPrice()) {
                    lowestId = supplierLineItem.getId();
                    lowestPrice = supplierLineItem.getPrice();
                }

            }

            unitPrice = lowestPrice;
            supplierLineItemId = lowestId;

            autoAddLineItem();
        }
    }

    public void displayRawMaterialPlanning(ActionEvent event) {

        rawMaterial = bOMSessionBean.getRawMaterialById(rawMaterialId);
        lotSize = rawMaterial.getLotSize();
        calculateEstQuantityLeft(rawMaterialId);


    }

    private boolean isExistingLingItem() {

        boolean flag = false;

        for (int i = 0; i < purchasingList.size(); i++) {

            if (purchasingList.get(i).getSupplierLineItemEntity().getId().equals(supplierLineItemId)) {
                flag = true;
                break;
            }
        }

        return flag;
    }

    public List<SelectItem> getRequiredRawMaterial() {

        List<SelectItem> selectItems = new ArrayList<SelectItem>();

        for (RawMaterialRequirementLineItemEntity lineItem : getRawMaterialRequirement().getRawMaterialRequirementLineItems()) {

            selectItems.add(new SelectItem(lineItem.getRawMaterial().getId(), lineItem.getRawMaterial().getRawMaterialName()));
        }
        return selectItems;
    }

    public void getRawMaterialSuppliers() {


        List<SelectItem> selectItems = new ArrayList<SelectItem>();

        if (rawMaterialId == null) {
            listOfSuppliers = new ArrayList();
            return;
        }

        setRawMaterial(bOMSessionBean.getRawMaterialById(getRawMaterialId()));


        for (SupplierLineItemEntity lineItem : rawMaterial.getSupplierLineItemList()) {

            selectItems.add(new SelectItem(lineItem.getId(), lineItem.getSupplier().getSupplierName()));
        }


        listOfSuppliers = selectItems;

        render = true;
        calculateRequiredQuantity();
    }

    public void updateFields(ActionEvent event) {


        getSupplierPrice();
        calculateLotSize();
        calculateCumAmount();
        calculateTotalQuantity();

    }

    public void updateRawMaterialFields() {

        getRawMaterialSuppliers();
        calculateEstQuantityLeft(rawMaterialId);

    }

    private void calculateTotalQuantity() {

        totalQuantity = lotSize * lotQuantity;
    }

    private void getSupplierPrice() {

        if (supplierLineItemId == null) {
            unitPrice = 0.0;
            return;
        }

        unitPrice = supplierSessionBean.getSupplierLineItemByID(getSupplierLineItemId()).getPrice();
    }

    private void calculateLotSize() {

        if (supplierLineItemId == null) {
            lotSize = 0;
            return;
        }

        lotSize = supplierSessionBean.getSupplierLineItemByID(getSupplierLineItemId()).getRawMaterial().getLotSize();
    }

    private void calculateCumAmount() {

        cumAmount = unitPrice * lotQuantity;
    }

    private void calculateRequiredQuantity() {

        boolean flag = true;
        for (RawMaterialRequirementLineItemEntity lineItem : rawMaterialRequirement.getRawMaterialRequirementLineItems()) {

            if (lineItem.getRawMaterial().getId().equals(rawMaterialId)) {
                flag = false;
                requiredQuantity = lineItem.getQuantity();
            }
        }
        if (flag) {
            requiredQuantity = 0;
        }
    }

    private void calculateEstQuantityLeft(Long rawMaterialId) {

        if (rawMaterialId == null) {

            return;
        }

        int leadTime = bOMSessionBean.getRawMaterialById(rawMaterialId).getLeadTime();
        Date date = rawMaterialRequirement.getForWeekStartingOn();
        productA = productManagementSessionBean.getProductById(1l);
        productB = productManagementSessionBean.getProductById(2l);
        productC = productManagementSessionBean.getProductById(3l);
        productD = productManagementSessionBean.getProductById(4l);
        WeeklyDetailEntity weeklyDetail = weeklyDetailSessionBean.getWeeklyDetailByDate(date);

        currentRawMaterialInventoryLevel = inventoryControlSessionBean.getInventoryByRMName(bOMSessionBean.getRawMaterialById(rawMaterialId).getRawMaterialName()).getCurrentLevel();
        weekOneRequired = calculateRequiredMaterial(weeklyDetail, rawMaterialId);

        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.WEEK_OF_YEAR, 1);
        date = c.getTime();

        weeklyDetail = weeklyDetailSessionBean.getWeeklyDetailByDate(date);
        weekTwoRequired = calculateRequiredMaterial(weeklyDetail, rawMaterialId);

        c.add(Calendar.WEEK_OF_YEAR, 1);
        date = c.getTime();

        weeklyDetail = weeklyDetailSessionBean.getWeeklyDetailByDate(date);
        weekThreeRequired = calculateRequiredMaterial(weeklyDetail, rawMaterialId);

        date = rawMaterialRequirement.getForWeekStartingOn();
        c.setTime(date);


        c.add(Calendar.WEEK_OF_YEAR, 0 - leadTime);
        date = c.getTime();
        List<RawMaterialPurchasingOrderEntity> rawMaterialPurchasingOrdersForAWeek = rawMaterialPurchasingSessionBean.getRawMaterialPurchasingOrdersForWeek(date);

        weekOneIncoming = calculateIncomingMaterial(rawMaterialPurchasingOrdersForAWeek, rawMaterialId);
        weekTwoEstQuantityLeft = 0;
        weekThreeEstQuantityLeft = 0;

        c.add(Calendar.WEEK_OF_MONTH, 1);
        date = c.getTime();
        rawMaterialPurchasingOrdersForAWeek = rawMaterialPurchasingSessionBean.getRawMaterialPurchasingOrdersForWeek(date);

        weekTwoIncoming = calculateIncomingMaterial(rawMaterialPurchasingOrdersForAWeek, rawMaterialId);


        c.add(Calendar.WEEK_OF_MONTH, 1);
        date = c.getTime();
        rawMaterialPurchasingOrdersForAWeek = rawMaterialPurchasingSessionBean.getRawMaterialPurchasingOrdersForWeek(date);

        weekThreeIncoming = calculateIncomingMaterial(rawMaterialPurchasingOrdersForAWeek, rawMaterialId);
        if (leadTime > 1) {
            if (leadTime > 2) {
                weekThreeEstQuantityLeft = getCurrentRawMaterialInventoryLevel() + getWeekOneIncoming() - getWeekOneRequired() + getWeekTwoIncoming() - getWeekTwoRequired() + getWeekThreeIncoming() - getWeekThreeRequired();

            }
            weekTwoEstQuantityLeft = getCurrentRawMaterialInventoryLevel() + getWeekOneIncoming() - getWeekOneRequired() + getWeekTwoIncoming() - getWeekTwoRequired();

        }
        weekOneEstQuantityLeft = getCurrentRawMaterialInventoryLevel() + getWeekOneIncoming() - getWeekOneRequired();


        switch (leadTime) {

            case 1:
                estQuantityLeft = getWeekOneEstQuantityLeft();

                break;
            case 2:
                estQuantityLeft = getWeekTwoEstQuantityLeft();

                break;
            case 3:
                estQuantityLeft = getWeekThreeEstQuantityLeft();

        }

        plannedOrderingQuantity = requiredQuantity - estQuantityLeft + getSafetyStock(rawMaterialId);

        
        System.out.println(plannedOrderingQuantity);
        System.out.println(requiredQuantity);
        System.out.println(estQuantityLeft);
        System.out.println(getSafetyStock(rawMaterialId));
  
        
        if (plannedOrderingQuantity < 0) {
            plannedOrderingQuantity = 0;
        }
        if (leadTime == 1) {
            weekonePlan = plannedOrderingQuantity;
            weektwoPlan = 0;
            weekthreePlan = 0;
        }
        if (leadTime == 2) {
            weekonePlan = 0;
            weektwoPlan = plannedOrderingQuantity;
            weekthreePlan = 0;
        }
        if (leadTime == 3) {
            weekonePlan = 0;
            weektwoPlan = 0;
            weekthreePlan = plannedOrderingQuantity;
        }

    }

    public int calculateIncomingMaterial(List<RawMaterialPurchasingOrderEntity> rawMaterialPurchasingOrdersForAWeek, Long id) {

        int result = 0;
        for (RawMaterialPurchasingOrderEntity purchaseOrder : rawMaterialPurchasingOrdersForAWeek) {
            for (RawMaterialPurchasingOrderLineItemEntity lineItem : purchaseOrder.getRawMaterialPurchasingOrderLineItems()) {

                if (lineItem.getRawMaterial().getId().equals(rawMaterialId)) {

                    result += lineItem.getTotalQuantity();
                    break;
                }
            }
        }

        return result;
    }

    public int calculateRequiredMaterial(WeeklyDetailEntity weeklyDetail, Long id) {

        int result = 0;
        if (weeklyDetail.getScheduleA() > 0) {

            List<BOMLineItemEntity> productBOMLineItemList = productA.getBillOfMaterials().getBomLineItems();
            for (BOMLineItemEntity bom : productBOMLineItemList) {

                if (bom.getRawMaterial().getId() == id) {

                    result += bom.getQuantity() * weeklyDetail.getScheduleA();
                    break;
                }
            }

        }

        if (weeklyDetail.getScheduleB() > 0) {

            List<BOMLineItemEntity> productBOMLineItemList = productB.getBillOfMaterials().getBomLineItems();
            for (BOMLineItemEntity bom : productBOMLineItemList) {

                if (bom.getRawMaterial().getId() == id) {

                    result += bom.getQuantity() * weeklyDetail.getScheduleB();
                    break;
                }
            }

        }
        if (weeklyDetail.getScheduleC() > 0) {

            List<BOMLineItemEntity> productBOMLineItemList = productC.getBillOfMaterials().getBomLineItems();
            for (BOMLineItemEntity bom : productBOMLineItemList) {

                if (bom.getRawMaterial().getId() == id) {

                    result += bom.getQuantity() * weeklyDetail.getScheduleC();
                    break;
                }
            }

        }

        if (weeklyDetail.getScheduleD() > 0) {

            List<BOMLineItemEntity> productBOMLineItemList = productD.getBillOfMaterials().getBomLineItems();
            for (BOMLineItemEntity bom : productBOMLineItemList) {

                if (bom.getRawMaterial().getId() == id) {

                    result += bom.getQuantity() * weeklyDetail.getScheduleD();
                    break;
                }
            }

        }

        return result;

    }

    public void deleteLineItem(RawMaterialPurchasingOrderLineItemEntity lineItem) {

        for (int i = 0; i < purchasingList.size(); i++) {

            if (purchasingList.get(i).getRawMaterial().getId().equals(lineItem.getRawMaterial().getId())) {
                purchasingList.remove(i);
                break;
            }
        }

    }

    public void generatePurchaseOrders(ActionEvent event) {

        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        currentUserId = (Long) request.getSession().getAttribute("userId");

        while (!purchasingList.isEmpty()) {

            if (nothingAdded) {

                System.out.println("=================================== generatePurchaseOrders is doing a infinate loop");
            }

            List<RawMaterialPurchasingOrderLineItemEntity> tempList = new ArrayList();
            nothingAdded = true;

            for (int i = 0; i < purchasingList.size(); i++) {


                boolean entered = false;

                RawMaterialPurchasingOrderLineItemEntity lineItem = purchasingList.get(i);

                if (rawMaterialPurchasingOrder.getSupplier() == null) {

                    nothingAdded = false;
                    rawMaterialPurchasingOrder.setSupplier(lineItem.getSupplierLineItemEntity().getSupplier());
                    rawMaterialPurchasingOrder.setDateGenerated(Calendar.getInstance().getTime());
                    tempList.add(lineItem);
                    purchasingList.remove(i);
                    i--;
                    continue;
                }

                if (rawMaterialPurchasingOrder.getSupplier().equals(lineItem.getSupplierLineItemEntity().getSupplier())) {


                    tempList.add(lineItem);
                    purchasingList.remove(i);
                    i--;
                }


            }
            if (!nothingAdded) {

                rawMaterialPurchasingOrder.setRawMaterialPurchasingOrderLineItems(tempList);
                rawMaterialPurchasingOrderList.add(rawMaterialPurchasingOrder);
                rawMaterialPurchasingSessionBean.addRawMaterialPurchaseOrder(rawMaterialPurchasingOrder);
                rawMaterialPurchasingOrder = new RawMaterialPurchasingOrderEntity();

            }

            if (!rawMaterialPurchasingOrderList.isEmpty()) {
                for (RawMaterialPurchasingOrderEntity purchaseOrder : rawMaterialPurchasingOrderList) {
                    generateRawMaterialPurchasingEmail(purchaseOrder);
                }
                informWarehouseDepartment();
            }

        }
        rawMaterialRequirement.setPurchasingOrderGenerated(true);
        rawMaterialPurchasingSessionBean.updateRawMaterial(rawMaterialRequirement);
    }

    private void informWarehouseDepartment() {

        List<EmployeeEntity> employeeList = employeeSessionBean.getAllEmployees();
        List<Long> idList = new ArrayList<Long>();
        for (int i = 0; i < employeeList.size(); i++) {
            if (employeeList.get(i).getDepartment().equals("Warehouse Department")) {
                idList.add(employeeList.get(i).getId());
            }
        }
        String type = "Broadcast";
        String content = "Dear Sir/Madam,\n"
                + "This week's raw material purchasing orders are generated.";
        messageSessionBean.addSystemMessage(currentUserId, idList, "New Purchase Order Generated", content, type);
    }

    private void generateRawMaterialPurchasingEmail(RawMaterialPurchasingOrderEntity purchaseOrder) {

        String content;
        content = "Dear Sir/Madam, \n"
                + "This is a purchase order from Merlion Food Limited.\n\n"
                + "Purchase Order Id: " + purchaseOrder.getId()
                + "\nTotal Price: " + purchaseOrder.getTotalPrice() + "\n";

        for (RawMaterialPurchasingOrderLineItemEntity lineItem : purchaseOrder.getRawMaterialPurchasingOrderLineItems()) {

            content = content
                    + "Line Item Id: " + lineItem.getId() + "    Material Name: " + lineItem.getRawMaterial().getRawMaterialName() + "    Quantity: " + lineItem.getTotalQuantity() + "   Proposed Price: " + lineItem.getSupplierLineItemEntity().getPrice() + "\n";
        }
        content = content + "\n\n Regards,\n Merlion Food Limited";

        emailSessilnBean.sendRawMaterialPurchasingEmail(purchaseOrder.getSupplier().getEmailAddress(), content);

    }

    /**
     * @return the purchasingList
     */
    public List<RawMaterialPurchasingOrderLineItemEntity> getPurchasingList() {
        return purchasingList;
    }

    /**
     * @return the rawMaterialRequirement
     */
    public RawMaterialRequirementEntity getRawMaterialRequirement() {
        return rawMaterialRequirement;
    }

    /**
     * @param rawMaterialRequirement the rawMaterialRequirement to set
     */
    public void setRawMaterialRequirement(RawMaterialRequirementEntity rawMaterialRequirement) {
        this.rawMaterialRequirement = rawMaterialRequirement;
    }

    /**
     * @return the rawMaterial
     */
    public RawMaterialEntity getRawMaterial() {
        return rawMaterial;
    }

    /**
     * @param rawMaterial the rawMaterial to set
     */
    public void setRawMaterial(RawMaterialEntity rawMaterial) {
        this.rawMaterial = rawMaterial;
    }

    /**
     * @return the rawMaterialId
     */
    public Long getRawMaterialId() {
        return rawMaterialId;
    }

    /**
     * @param rawMaterialId the rawMaterialId to set
     */
    public void setRawMaterialId(Long rawMaterialId) {
        this.rawMaterialId = rawMaterialId;
    }

    /**
     * @return the supplierLineItemId
     */
    public Long getSupplierLineItemId() {
        return supplierLineItemId;
    }

    /**
     * @param supplierLineItemId the supplierLineItemId to set
     */
    public void setSupplierLineItemId(Long supplierLineItemId) {
        this.supplierLineItemId = supplierLineItemId;
    }

    /**
     * @return the lotQuantity
     */
    public int getLotQuantity() {
        return lotQuantity;
    }

    /**
     * @param lotQuantity the lotQuantity to set
     */
    public void setLotQuantity(int lotQuantity) {
        this.lotQuantity = lotQuantity;
    }

    /**
     * @return the lotSize
     */
    public int getLotSize() {
        return lotSize;
    }

    /**
     * @return the unitPrice
     */
    public double getUnitPrice() {
        return unitPrice;
    }

    /**
     * @return the cumAmount
     */
    public double getCumAmount() {
        return cumAmount;
    }

    /**
     * @return the listOfSuppliers
     */
    public List<SelectItem> getListOfSuppliers() {
        return listOfSuppliers;
    }

    /**
     * @return the requiredQuantity
     */
    public double getRequiredQuantity() {
        return requiredQuantity;
    }

    /**
     * @return the totalQuantity
     */
    public double getTotalQuantity() {
        return totalQuantity;
    }

    /**
     * @return the weekOneRequired
     */
    public double getWeekOneRequired() {
        return weekOneRequired;
    }

    /**
     * @return the weekTwoRequired
     */
    public double getWeekTwoRequired() {
        return weekTwoRequired;
    }

    /**
     * @return the weekThreeRequired
     */
    public double getWeekThreeRequired() {
        return weekThreeRequired;
    }

    /**
     * @return the weekOneIncoming
     */
    public double getWeekOneIncoming() {
        return weekOneIncoming;
    }

    /**
     * @return the weekTwoIncoming
     */
    public double getWeekTwoIncoming() {
        return weekTwoIncoming;
    }

    /**
     * @return the weekThreeIncoming
     */
    public double getWeekThreeIncoming() {
        return weekThreeIncoming;
    }

    /**
     * @return the weekOneEstQuantityLeft
     */
    public double getWeekOneEstQuantityLeft() {
        return weekOneEstQuantityLeft;
    }

    /**
     * @return the weekTwoEstQuantityLeft
     */
    public double getWeekTwoEstQuantityLeft() {
        return weekTwoEstQuantityLeft;
    }

    /**
     * @return the weekThreeEstQuantityLeft
     */
    public double getWeekThreeEstQuantityLeft() {
        return weekThreeEstQuantityLeft;
    }

    /**
     * @return the estQuantityLeft
     */
    public double getEstQuantityLeft() {
        return estQuantityLeft;
    }

    /**
     * @return the currentRawMaterialInventoryLevel
     */
    public double getCurrentRawMaterialInventoryLevel() {
        return currentRawMaterialInventoryLevel;
    }

    /**
     * @return the render
     */
    public boolean isRender() {
        return render;
    }

    /**
     * @return the plannedOrderingQuantity
     */
    public double getPlannedOrderingQuantity() {
        return plannedOrderingQuantity;
    }

    public double getWeekonePlan() {
        return weekonePlan;
    }

    public void setWeekonePlan(double weekonePlan) {
        this.weekonePlan = weekonePlan;
    }

    public double getWeektwoPlan() {
        return weektwoPlan;
    }

    public void setWeektwoPlan(double weektwoPlan) {
        this.weektwoPlan = weektwoPlan;
    }

    public double getWeekthreePlan() {
        return weekthreePlan;
    }

    public void setWeekthreePlan(double weekthreePlan) {
        this.weekthreePlan = weekthreePlan;
    }
}
